﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace WpfScratchApp.ViewModel
{
    class ByteViewModel : INotifyPropertyChanged 
    {
        private byte _value;
        private byte _value2;

        public byte Value
        {
            get { return _value; }
            set
            {
                _value = value;
                RaisePropertyChanged("Value");
                RaisePropertyChanged("ValueAnd");
                RaisePropertyChanged("ValueOr");
                RaisePropertyChanged("ValueXor");
            }
        }

        public byte Value2
        {
            get { return _value2; }
            set
            {
                _value2 = value;
                RaisePropertyChanged("Value2");
                RaisePropertyChanged("ValueAnd");
                RaisePropertyChanged("ValueOr");
                RaisePropertyChanged("ValueXor");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        
        protected void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        public byte ValueAnd
        {
            get { return Convert.ToByte(Value & Value2); }
        }

        public byte ValueOr
        {
            get { return Convert.ToByte(Value | Value2); }
        }

        public byte ValueXor
        {
            get { return Convert.ToByte(Value ^ Value2); }
        }

    }
}
